package url

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

// Login 定义接收数据的结构体
type Login struct {
	// binding:"required"修饰的字段，若接收为空值，则报错，是必须字段
	User     string `form:"username" json:"user" uri:"user" xml:"user" binding:"required"`
	Password string `form:"password" json:"password" uri:"password" xml:"password" binding:"required"`
}

func init() {
	r := gin.Default()
	r.GET("login/:user/:password", func(context *gin.Context) {
		var login Login
		if err := context.ShouldBindUri(&login); err != nil {
			context.JSON(http.StatusOK, gin.H{"error": err.Error()})
			return
		}
		context.JSON(http.StatusOK, gin.H{"code": "200"})
	})
	r.Run(":8000")
}
